Fix generating lingua.selector url to other language on HTTPS #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Line 208 of the
lingua.selector
snippet has the followingpreg_replace
to generate the other language url:That's trying to find
$parseUrl['scheme'] . '://' . $parseUrl['host'] . '/' . $requestUri
in$originPageUrl
, to replace it with the (correct)$parseUrl['scheme'] . '://' . $parseUrl['host'] . '/' . $baseUrl . $itemUri
.Because HTTPS is (transparently) served on port 443, the port is injected into
$pageURL
here in line 55 and therefore around line 175 into the subject of this replace,$originPageUrl
.Because
$parseUrl['host']
does not have the port, thepreg_replace
fails and the user is given the current link with?lang=foo
added. While that works to switch the language, the user wants to see the proper localised url and not the current one.By not adding the port if it's 443, the preg_replace matches as expected and the right URL is returned.